﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace EventBus.RabbitMQ
{
    public static class RabbitmqConfigureServices
    {
        public static void RabbitmqBus(this IServiceCollection services, RabbitMQOptions options, Assembly[] assemblies, HandlerType handlerType) 
        {
            services.AddSingleton<IOptions<RabbitMQOptions>>(options);
            services.AddSingleton<IConnectionChannel, ConnectionChannel>();
            services.AddSingleton<IRabbitMqPublisher, RabbitMqPublisher>();
            services.AddSingleton<IRabbitMqSubscriber, RabbitMqSubscriber>();
            services.RegisterHandler(assemblies, handlerType);
        }
    }
}
